package com.meritit.config;

import java.util.concurrent.TimeUnit;

public class HookTest {

	private static Thread t = null;;
	
	public void start() {
		
		t = new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println("execute hook...");
			}
		});
		
		Runtime.getRuntime().addShutdownHook(t);
	}
	
	public static void main(String[] args) {
		new HookTest().start();
		
		System.out.println("The Application is doing something");
		
//		Runtime.getRuntime().removeShutdownHook(t);

		System.exit(0);
		
		try {
			TimeUnit.SECONDS.sleep(5);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}
	
}
